package cn.com.dhcc.app.pub.module.login.vo;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import cn.com.dhcc.app.core.base.user.AuthUserType;
import cn.com.dhcc.app.core.util.CollectionUtil;
import cn.com.dhcc.app.pub.module.authmgr.vo.RoleInfoInner;

/**
 * 登录自定义信息
 * @author qiao
 * 2017-5-11 下午4:46:34
 */
public class LoginCustomData {

	private List<RoleInfoInner> innerRoles;
	private Object ssoRawUserInfo;
	private String depCode;
	private String orgCode;
	private String adminOrgCode;
	private String adminPwd;
	public List<RoleInfoInner> getInnerRoles() {
		return innerRoles;
	}

	public void setInnerRoles(List<RoleInfoInner> innerRoles) {
		this.innerRoles = innerRoles;
	}

	public Object getSsoRawUserInfo() {
		return ssoRawUserInfo;
	}

	public void setSsoRawUserInfo(Object ssoRawUserInfo) {
		this.ssoRawUserInfo = ssoRawUserInfo;
	}

	public String getDepCode() {
		return depCode;
	}

	public void setDepCode(String depCode) {
		this.depCode = depCode;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getAdminOrgCode() {
		return adminOrgCode;
	}

	public void setAdminOrgCode(String adminOrgCode) {
		this.adminOrgCode = adminOrgCode;
	}
	
	public String getAdminPwd() {
		return adminPwd;
	}

	public void setAdminPwd(String adminPwd) {
		this.adminPwd = adminPwd;
	}

	/**
	 * 获取当前登陆用户的角色类型列表
	 * @param httpSession
	 * @return
	 */
	public static Set<AuthUserType>  getLoginUserTypeFromUserRole(List<RoleInfoInner> roles){
		if(CollectionUtil.hasElement(roles)){
			Set<AuthUserType> authUserTypes  = new HashSet<AuthUserType>();
			for (Iterator<RoleInfoInner> iterator = roles.iterator(); iterator.hasNext();) {
				RoleInfoInner roleInfo = (RoleInfoInner) iterator.next();
				String roleType = roleInfo.getRoleType();
				AuthUserType userType = AuthUserType.getAuthUserType(roleType);
				if(userType!=null){
					authUserTypes.add(userType);
				}
			}
			return authUserTypes;
		}
		return null;
	}
}
